<?php
/*
 *                        _oo0oo_
 *                       o8888888o
 *                       88" . "88
 *                       (| -_- |)
 *                       0\  =  /0
 *                     ___/`---'\___
 *                   .' \\|     |// '.
 *                  / \\|||  :  |||// \
 *                 / _||||| -:- |||||- \
 *                |   | \\\  - /// |   |
 *                | \_|  ''\---/''  |_/ |
 *                \  .-\__  '-'  ___/-. /
 *              ___'. .'  /--.--\  `. .'___
 *           ."" '<  `.___\_<|>_/___.' >' "".
 *          | | :  `- \`.;`\ _ /`;.`/ - ` : | |
 *          \  \ `_.   \_ __\ /__ _/   .-` /  /
 *      =====`-.____`.___ \_____/___.-`___.-'=====
 *                        `=---='
 * 
 * 
 *      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 * 
 *            佛祖保佑       永不宕机     永无BUG
 */
/*
 * 职位操作页
 * @Author: htong
 * @Date: 2021-03-02 18:16:55
 * @LastEditors: htong
 * @LastEditTime: 2021-03-02 18:39:06
 * @Description: file content
 * @FilePath: \gongchengqiaojob\Application\Home\Controller\PcPositionapiController.class.php
 */
namespace Home\Controller;
use Common\Controller\PcApiController;
use Common\ORG\PublicFunction;
use Common\ORG\WxFunction;
use Think\Db;

class PcPositionapiController extends PcApiController{
	
	public function _initialize() {

        $getsecret  = $_SERVER['HTTP_APPSECRET'];
        //取head标签内容
        if(!preg_match('/^\w{8}-\w{4}-\w{4}-\w{4}-\w{12}$/', $getsecret) && ACTION_NAME<>'getUserInfo'){
            $this->ajaxReturn(1, 'appsecret格式错误');
        }

        if($this->appsecret <> $getsecret && ACTION_NAME<>'getUserInfo'){
            $this->ajaxReturn(1, 'appsecret错误');
        }
        parent::_initialize();
    }

	/**
     * 职位列表
     */
    public function positionList(){
        $Recruitmenttype = I('Recruitmenttype',1); //招聘类型 1.常规 2.急招 3.短期 4.项目专场 5.悬赏
        $audit = I('audit',1); //状态 1.发布中 2.审核中3.未通过 4 已暂停 5 已到期 
        $page = I('page',1); //页数
        $pagesize = I('pagesize',10); //每页条数
        $where = [];
        $where['s.uid'] = $this->userinfo['uid'];
        //招聘类型
        if($Recruitmenttype){
            $where['s.old_zhao_type_id'] = ['eq',$Recruitmenttype];
        }
        //状态
        if($audit){
            $where['s.audit'] = ['eq',$audit];
        }
        $positionList = M('jobs s')
                    ->field('s.id,s.jobs_name,s.companyname,s.district_cn,s.zhao_end_time,s.addtime,s.refreshtime,s.reason')
                    ->where($where)
                    ->page($page,$pagesize)
                    ->group('s.id')
                    ->select();
        foreach($positionList as $k=>$v){
            $positionList[$k]['deliverynum'] = M('personal_jobs_apply')->where(['jobs_id'=>$v['id']])->count();
            $positionList[$k]['zhao_end_time'] = date('Y.m.d',strtotime($v['zhao_end_time']));
            $positionList[$k]['addtime'] =date('Y.m.d',$v['addtime']);
            $positionList[$k]['refreshtime'] =date('Y.m.d',$v['refreshtime']);
        }

        $this->ajaxReturn(0, 'ok',$positionList );            
  
    }
	/**
     * 发布职位入口
     */
    public function positionAddEntrance(){
        $data = array();
        $company_profile = D('CompanyProfile')->field('logo,companyname')->where(array('uid'=> $this->userinfo['uid']))->find();
        $data['uid'] = $this->userinfo['uid'];
        $data['companyname'] = $company_profile['companyname'];
        $data['categorypin'] = $this->get_type_list_copy();//发布的招聘类型
        $data['jobswlist'] = $this->get_jobsw_list();//职位类别
        $data['tradelist'] = $this->get_major_list();//所属行业
        $data['citylist'] = $this->get_city_parent_list_two();//城市
        $data['citylist2'] = $this->get_city_parent_list();//城市
        $data['experiencelist'] = $this->get_experience_list();//工作经验
        $data['wagelist'] = $this->get_wage_list();//期望薪资
        $data['educationlist'] = $this->get_education_list();//获取学历要求
        $data['language_level']  = D('Category')->category_get_by_alias('QS_language_level', 'language_level'); //语言等级
        $data['jobtag']  = D('Category')->category_get_by_alias('QS_jobtag', 'jobtag');//福利标签
        $trade_list =  D('Category')->get_category_cache()['QS_dutytime'];//到岗时间
        $data['work_time'] = D('Category')->category_get_by_alias('QS_work_time', 'work_time'); //工作时间
        foreach($trade_list as $k=>$v){
                       $trade_lst[$k]['id']=$k;
                       $trade_lst[$k]['value']=$v;
                   }
        $trade_list=array_values($trade_lst);
        $data['nature']  =$trade_list;
        $data['nature_list']  = $this->get_nature_list();//工作性质//工作性
        $data['languagelist'] = $this->get_language_list();//语言
        $this->ajaxReturn(0, 'ok',$data ); 
    }

}
?>